<?php
require_once 'StaffDB.php';

try {
    // 实例化StaffDB，无需传递参数
    $staffDB = new StaffDB();
    
    // 示例1：创建新员工（不提供guid）
    $newStaff = [
        'id' => 20070020,
        'name' => '彭涛',
        'qualifications' => [
            'qualifications' => ['带班主任', '监控席', '教员'],
            'qualificationIds' => [1, 2, 3]
        ],
        'organizations' => [
            'organizations' => ['管制一室'],
            'organizationsIds' => [1]
        ],
        'groups' => [
            'groups' => ['B3'],
            'groupIds' => [3]
        ],
        'availableSeats' => [
            'availableSeats' => ['TM01', 'TM02'],
            'availableSeatIds' => ['TM01', 'TM02']
        ],
        'marks' => [
            'marks' => ['终点关注', '涉密'],
            'markIds' => [100, 200]
        ],
        'temporaryRoles' => []
    ];
    
    // 创建员工，自动生成guid
    $generatedGuid = $staffDB->createStaff($newStaff);
    echo "新员工创建成功，生成的GUID: " . $generatedGuid . "\n";
    
    // 示例2：读取员工信息
    $staff = $staffDB->getStaffByGuid($generatedGuid);
    if ($staff) {
        echo "读取成功:\n";
        print_r($staff);
    }
    
    // 示例3：更新员工信息
    $updateData = $newStaff;
    $updateData['guid'] = $generatedGuid;
    $updateData['name'] = '彭涛（更新后）';
    $updateResult = $staffDB->updateStaff($updateData);
    if ($updateResult) {
        echo "员工信息更新成功\n";
    }
    
    // 示例4：删除员工信息
    $deleteResult = $staffDB->deleteStaff($generatedGuid);
    if ($deleteResult) {
        echo "GUID为 $generatedGuid 的员工信息已成功删除\n";
    }
    
} catch (Exception $e) {
    echo "操作失败: " . $e->getMessage() . "\n";
}
?>
    